package com.zxl.grocery.microservice.zuulgateway.server;


import com.zxl.grocery.microservice.auth.client.EnableGroceryAuthClient;
import com.zxl.grocery.microservice.zuulgateway.ratelimit.EnableAceGateRateLimit;
import com.zxl.grocery.microservice.zuulgateway.ratelimit.config.IUserPrincipal;
import com.zxl.grocery.microservice.zuulgateway.server.config.UserPrincipal;
import com.zxl.grocery.microservice.zuulgateway.server.utils.DBLog;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * @Author: zxl
 * @Description:
 * @Date: Created in 23:43 2017/10/14
 * @Modified By:
 */
@SpringBootApplication
//@EnableDiscoveryClient
@EnableFeignClients({"com.zxl.grocery.microservice.auth.client.feign","com.zxl.grocery.microservice.zuulgateway.server.feign"})
@EnableZuulProxy //组合注解 包含@EnableCircuitBreaker ：Hystrix ；@EnableDiscoveryClient //服务发现客户端
@EnableScheduling
@EnableGroceryAuthClient
@EnableAceGateRateLimit
public class GateWayBootstrap {
    public static void main(String[] args) {
        DBLog.getInstance().start();
        SpringApplication.run(GateWayBootstrap.class, args);
    }

    @Bean
    @Primary
    IUserPrincipal userPrincipal(){
        return new UserPrincipal();
    }
}
